package com.zjq.controller;

import com.zjq.pojo.Order;
import com.zjq.pojo.User;
import com.zjq.service.BookService;
import com.zjq.service.BookStoreService;
import com.zjq.service.OrderListService;
import com.zjq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.awt.print.Book;
import java.util.List;

@Controller
@RequestMapping
public class MymessageController {

    @Autowired
    @Qualifier("UserServiceImpl")
    private UserService userService;

    @Autowired
    @Qualifier("BookStoreServiceImpl")
    private BookStoreService bookStoreService;

    @Autowired
    @Qualifier("BookServiceImpl")
    private BookService bookService;

    @Autowired
    @Qualifier("OrderListServiceImpl")
    private OrderListService orderListService;

    @RequestMapping("/Mymessage")
    public String Mymessage(int id, Model model){
        List<Order> orders = orderListService.queryOrder(id);
        User user = userService.queryUserById(id);
        model.addAttribute("user",user);
        model.addAttribute("order",orders);
        return "bookstore/myMessage";
    }

    @RequestMapping("/toMessage")
    @ResponseBody
    public User toMessage(int id){
        User user = userService.queryUserById(id);
        return user;
    }


}
